//
//  CellOfLeave.m
//  PetAPP
//
//  Created by apple on 16/3/5.
//  Copyright © 2016年 Yuming. All rights reserved.
//

#import "CellOfLeave.h"
#import <DKNightVersion.h>

@interface CellOfLeave ()

@property (nonatomic, retain) UIButton *buttonOfLeave;

@end

@implementation CellOfLeave

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {
    
    self.buttonOfLeave = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:_buttonOfLeave];
    [_buttonOfLeave release];

}

- (void)layoutSubviews {
    [super layoutSubviews];
    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"loginState"] boolValue]) {
        self.buttonOfLeave.hidden = NO;
    }else {
        self.buttonOfLeave.hidden = YES;
    }
    self.buttonOfLeave.frame = CGRectMake(20, 30, self.contentView.frame.size.width - 40, 40);
    self.buttonOfLeave.layer.cornerRadius = 5;
    self.buttonOfLeave.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:255/256.0 green:207/256.0 blue:87/256.0 alpha:1], [UIColor grayColor]);
    
    [self.buttonOfLeave setTitle:@"退出登录" forState:UIControlStateNormal];
    [self.buttonOfLeave dk_setTitleColorPicker:DKColorWithColors([UIColor brownColor], [UIColor whiteColor]) forState:UIControlStateNormal];
    self.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:0.9625 green:0.9625 blue:0.9625 alpha:1.0], [UIColor colorWithRed:0.2952 green:0.2952 blue:0.2952 alpha:1.0]);
    
    [self.buttonOfLeave addTarget:self action:@selector(handleButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)handleButtonAction:(UIButton *)button {
    
    [self.delegate handleLeaveLogin];
       
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
